package a66weding.com.jiehuntong.activity.home;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.TextView;
import com.andview.refreshview.XRefreshView;
import com.bumptech.glide.Glide;
import org.xutils.common.util.DensityUtil;
import java.util.ArrayList;
import java.util.List;
import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.activity.ShopDetailsActivity;
import a66weding.com.jiehuntong.application.GlobalApplication;
import a66weding.com.jiehuntong.beans.CateguryGridViewBean;
import a66weding.com.jiehuntong.beans.CityAreaBean;
import a66weding.com.jiehuntong.beans.CommonResultBean;
import a66weding.com.jiehuntong.beans.ErrorBean;
import a66weding.com.jiehuntong.beans.HttpRequestBean;
import a66weding.com.jiehuntong.beans.ShoplistBean;
import a66weding.com.jiehuntong.beans.SuccessBean;
import a66weding.com.jiehuntong.common.CommonAdapter;
import a66weding.com.jiehuntong.common.MyViewHolder;
import a66weding.com.jiehuntong.common.utils.CUtils;
import a66weding.com.jiehuntong.http.HttpHandleUtil;
import a66weding.com.jiehuntong.http.OnNetResultListener;
import a66weding.com.jiehuntong.http.RequestCode;
public class HomeFindbusinshopActivity extends BaseHomeActivity implements View.OnClickListener, OnNetResultListener, CompoundButton.OnCheckedChangeListener {
    private TextView mTitleTv;
    private TextView mBackTv;
    private TextView mHeadRightfuncTv;
    private LinearLayout mBackLay;
    private LinearLayout mProgressLay;
    private LinearLayout mSelectLAy;
    private TextView mAllshopLay;
    private TextView mAreaLay;
    private TextView mOrderLay;
    private LinearLayout mContentLay;
    private LinearLayout mNoNetLay;
    private XRefreshView xRefreshView;
    private ListView shopListView;
    private PopupWindow mAllshopPop;
    private PopupWindow mAreaPop;
    private CommonAdapter<ShoplistBean.DataBean> mContentAdapter;
    private List<ShoplistBean.DataBean> shoplistBean;
    private long lastRefreshTime= System.currentTimeMillis();
    private List<CateguryGridViewBean.DataBean> categryListData;
    private List<CityAreaBean.DataBean> cityAreaList;
    private static int selectModel;
    private int areaID = 0;
    private RadioButton defaultRbtn;
    private RadioButton collectRbtn;
    private RadioButton releaseRbtn;
    private int pageIndex=1;
    private int winwidth;
    private int winheight;
    private MyListAdapter mAdaPter;
    private int categoryId = 1;
    private int orderIndex=3;
    private int mCurrentIndex;
    private boolean isrefresh;
    private boolean isloadmore;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_findbusinshop);
        ((GlobalApplication) getApplication()).getActivityManager().addActivity("HomeFindbusinshopActivity", this);
        initview();
        initdata();
        getdataFromNet(1,categoryId+"",areaID,"2",3);
        getCategurydataFromNet();
        getCitydataFromNet();
    }
    private void getdataFromNet(int pageIndex,String category,int areaId,String city,int order) {
        //get请求  &category={category}&area={area}&city={city}&order={order}&pageIndex={pageIndex}&memberID={memberID}
        String url= RequestCode.get_BusinessList;
        url += "&category="+category+"&area="+areaId+"&city="+city+"&order="+order+"&pageIndex="+pageIndex+"&memberID="+0;
        HttpRequestBean httpRequestBean = new HttpRequestBean(RequestCode.GETREQUEST,url,this, ShoplistBean.class,RequestCode.get_BusinessList);
        HttpHandleUtil.executeCommonGet(this,httpRequestBean);
    }

    private void getCategurydataFromNet() {
        //get请求  &category={category}&area={area}&city={city}&order={order}&pageIndex={pageIndex}&memberID={memberID}
        String url= RequestCode.CATEGURYGRIDVIEW;
        HttpRequestBean httpRequestBean = new HttpRequestBean(RequestCode.GETREQUEST,url,this, CateguryGridViewBean.class,RequestCode.CATEGURYGRIDVIEW);
        HttpHandleUtil.executeCommonGet(this,httpRequestBean);

    }
    private void getCitydataFromNet() {
        //get请求
        String url= RequestCode.get_AreaList;
        HttpRequestBean httpRequestBean = new HttpRequestBean(RequestCode.GETREQUEST,url,this, CityAreaBean.class,RequestCode.CATEGURYGRIDVIEW);
        HttpHandleUtil.executeCommonGet(this,httpRequestBean);

    }
    private void initview() {
        mTitleTv = (TextView) findViewById(R.id.tv_header_title);
        mBackTv = (TextView) findViewById(R.id.tv_header_backcontent);
        mBackLay = (LinearLayout) findViewById(R.id.llay_header_back);
        mHeadRightfuncTv = (TextView) findViewById(R.id.tv_header_function);
        mAllshopLay = (TextView) findViewById(R.id.llay_allshop);
        mAreaLay = (TextView) findViewById(R.id.tv_area);
        mOrderLay = (TextView) findViewById(R.id.tv_order);
        mProgressLay = (LinearLayout) findViewById(R.id.progressLay);
        mContentLay = (LinearLayout) findViewById(R.id.lay_shoplist_content);
        mNoNetLay = (LinearLayout) findViewById(R.id.lay_shoplist_nonet);
        mSelectLAy = (LinearLayout) findViewById(R.id.lay_selectLay);
        xRefreshView = (XRefreshView) findViewById(R.id.shoplist_xrefreshview);
        shopListView = (ListView) findViewById(R.id.lview_shoplist);
        mTitleTv.setText("找商家");
        mBackTv.setText("首页");
        mHeadRightfuncTv.setVisibility(View.GONE);
        mBackLay.setOnClickListener(this);
        mAllshopLay.setOnClickListener(this);
        mNoNetLay.setOnClickListener(this);
        mAreaLay.setOnClickListener(this);
        mOrderLay.setOnClickListener(this);
        initRefreshView();
    }
    private void initdata() {
        WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        winwidth = wm.getDefaultDisplay().getWidth();
        winheight = wm.getDefaultDisplay().getHeight();
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
                case R.id.llay_header_back:
                    resetPageIndex();
                    finish();
                break;
                 case  R.id.llay_allshop:
                     mAllshopLay.setTextColor(getResources().getColor(R.color.colorMainRed));
                     Drawable drawable = getResources().getDrawable(R.mipmap.arror_red_down);
                     drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                     mAllshopLay.setCompoundDrawables(null, null, drawable,null);
                     resetPageIndex();
                     if (mAllshopPop != null) {
                         mAllshopPop.dismiss();
                         mAllshopPop = null;
                     }
                     if(categryListData!=null) {
                        showPopupWindow(view);
                     }
                break;
                 case  R.id.tv_all:
                     resetPageIndex();
                     getdataFromNet(1,categoryId+"",areaID,"2",3);
                     if(mCurrentIndex==1) {
                         mAllshopLay.setText("全部");
                         categoryId = 1;
                         getdataFromNet(1,categoryId+"",areaID,"2",3);
                         mAllshopLay.setTextColor(getResources().getColor(R.color.colorFontGray2));
                         mAllshopLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_gray_down),null);
                     }else if(mCurrentIndex==2){
                         mAreaLay.setText("全城");
                         areaID = 0;
                         getdataFromNet(1,categoryId+"",areaID,"2",3);
                         mAreaLay.setTextColor(getResources().getColor(R.color.colorFontGray2));
                         mAreaLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_gray_down),null);
                     }
                     if(mAllshopPop!=null) {
                         mAllshopPop.dismiss();
                     }
                     if(mAreaPop!=null) {
                         mAreaPop.dismiss();
                     }
                break;
                 case  R.id.tv_area://全部地区
                     mAreaLay.setTextColor(getResources().getColor(R.color.colorMainRed));
                     mAreaLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_red_down),null);
                     resetPageIndex();
                     if (mAreaPop != null) {
                         mAreaPop.dismiss();
                         mAreaPop = null;
                     }
                     if(cityAreaList!=null) {
                        showAreaPopupWindow(view);
                     }
                break;
                 case  R.id.tv_order://默认排序
                     resetPageIndex();
                     if (mAreaPop != null) {
                         mAreaPop.dismiss();
                         mAreaPop = null;
                     }
                     if(cityAreaList!=null) {
                        showOrderPopupWindow(view);
                     }
                break;
                 case  R.id.rbtn_defaultorder:
                     resetPageIndex();
                     defaultRbtn.setChecked(true);
                     if (defaultRbtn.isChecked()) {
                         getdataFromNet(1, String.valueOf(categoryId), areaID, "2", 3);
                     }
                     collectRbtn.setChecked(false);
                     releaseRbtn.setChecked(false);
                     if(mAreaPop!=null) {
                         mAreaPop.dismiss();
                     }
                break;
                 case  R.id.rbtn_collectorder:
                     resetPageIndex();
                     collectRbtn.setChecked(true);
                     collectRbtn.setChecked(true);
                     if (collectRbtn.isChecked()) {
                         getdataFromNet(1, String.valueOf(categoryId), areaID, "2", orderIndex);

                     }

                     defaultRbtn.setChecked(false);
                     releaseRbtn.setChecked(false);

                     if(mAreaPop!=null) {
                         mAreaPop.dismiss();
                     }
                break;
                 case  R.id.rbtn_newreleasectorder:
                     resetPageIndex();
                     releaseRbtn.setChecked(true);
                     releaseRbtn.setChecked(true);
                     if (releaseRbtn.isChecked()) {
                         getdataFromNet(1, String.valueOf(categoryId), areaID, "2", orderIndex);
                     }
                     defaultRbtn.setChecked(false);
                     collectRbtn.setChecked(false);
                     if(mAreaPop!=null) {
                         mAreaPop.dismiss();
                     }
                break;
                 case  R.id.lay_shoplist_nonet:
                     getdataFromNet(1,categoryId+"",0,"2",3);
                break;
        }
    }
    //显示窗体
    private void showPopupWindow(View rootview) {
        //设置contentView
        final View contentView = LayoutInflater.from(HomeFindbusinshopActivity.this).inflate(R.layout.pop_product_select, null);
        contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        mAllshopPop = new PopupWindow(contentView, WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT, true);
        mAllshopPop.setFocusable(true);
        mAllshopPop.setOutsideTouchable(true);
        mAllshopPop.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.whitetranslucenthalf2)));
        mCurrentIndex=1;
        //设置各个控件的点击响应
        ListView lv_popupwindow = (ListView) contentView.findViewById(R.id.lv_popupwindow);
        List<String> catageryList=new ArrayList<String>();
        for (int i = 0; i < categryListData.size(); i++) {
            catageryList.add(categryListData.get(i).getNvc_Name());
        }
        mAdaPter=new MyListAdapter(catageryList,"全部");
        lv_popupwindow.setAdapter(mAdaPter);
        lv_popupwindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                CateguryGridViewBean.DataBean dataBean = categryListData.get(position);
                String nvc_name = dataBean.getNvc_Name();
                categoryId = dataBean.getI_Id();
                selectModel=1;
                resetPageIndex();
                mAllshopLay.setText(nvc_name);
                mAllshopLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_red_down),null);
                getdataFromNet(1, categoryId +"",areaID,"2",3);
                if(mAllshopPop!=null) {
                    mAllshopPop.dismiss();
                }
            }
        });
        contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAllshopPop.dismiss();
            }
        });
        mAllshopPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mCurrentIndex=0;
            }
        });
        mAllshopPop.showAsDropDown(mSelectLAy);
    }

    //显示窗体
    private void showAreaPopupWindow(View rootview) {
        //设置contentView
        View contentView = LayoutInflater.from(HomeFindbusinshopActivity.this).inflate(R.layout.pop_product_select, null);
        mAreaPop = new PopupWindow(contentView, WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT, true);
        mAreaPop.setContentView(contentView);
        mAreaPop.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.whitetranslucenthalf2)));
        ListView lv_popupwindow = (ListView) contentView.findViewById(R.id.lv_popupwindow);
        List<String> arrearList=new ArrayList<String>();
        for (int i = 0; i < cityAreaList.size(); i++) {
            arrearList.add(cityAreaList.get(i).getAreaName());
        }
        mAdaPter=new MyListAdapter(arrearList,"全城");
        lv_popupwindow.setAdapter(mAdaPter);
        mCurrentIndex=2;
        lv_popupwindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                CityAreaBean.DataBean dataBean = cityAreaList.get(position);
                mAreaLay.setText(dataBean.getAreaName());
                areaID = dataBean.getI_ID();
                mAreaLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_red_down),null);
                selectModel=2;
                resetPageIndex();
                getdataFromNet(1, categoryId+"",areaID,"2",3);
                if(mAreaPop!=null) {
                    mAreaPop.dismiss();
                }
            }
        });
        contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAreaPop.dismiss();
            }
        });
        mAreaPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mCurrentIndex=0;
            }
        });
        mAreaPop.showAsDropDown(mSelectLAy);
    }

    //显示窗体
    private void showOrderPopupWindow(View rootview) {
        //设置contentView
        View contentView = LayoutInflater.from(HomeFindbusinshopActivity.this).inflate(R.layout.item_product_shoporder, null);
        defaultRbtn = (RadioButton) contentView.findViewById(R.id.rbtn_defaultorder);
        collectRbtn = (RadioButton) contentView.findViewById(R.id.rbtn_collectorder);
        releaseRbtn = (RadioButton) contentView.findViewById(R.id.rbtn_newreleasectorder);
        defaultRbtn.setOnClickListener(HomeFindbusinshopActivity.this);
        collectRbtn.setOnClickListener(HomeFindbusinshopActivity.this);
        releaseRbtn.setOnClickListener(HomeFindbusinshopActivity.this);
        defaultRbtn.setOnCheckedChangeListener(HomeFindbusinshopActivity.this);
        collectRbtn.setOnCheckedChangeListener(HomeFindbusinshopActivity.this);
        releaseRbtn.setOnCheckedChangeListener(HomeFindbusinshopActivity.this);
        switch (orderIndex) {
                case 1:
                    collectRbtn.setChecked(true);
                break;
                 case 2:
                     releaseRbtn.setChecked(true);
                break;
                 case 3:
                     defaultRbtn.setChecked(true);
                break;
        }
        mAreaPop = new PopupWindow(contentView, winwidth, winheight, true);
        mAreaPop.setContentView(contentView);
        mAreaPop.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.whitetranslucenthalf2)));
        mAreaPop.setOutsideTouchable(true);
        mAreaPop.setTouchable(true);
        contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAreaPop.dismiss();
            }
        });
        mAreaPop.showAsDropDown(mSelectLAy);
    }
    @Override
    public void onSucess(SuccessBean sucessbean) {
        Object data = sucessbean.getData();
        notifyViewLay(HAVEDATA);
        if(data instanceof CommonResultBean) {
        }else if(data instanceof ShoplistBean){
            if(mAreaPop!=null) {
                mAreaPop.dismiss();
                mAllshopPop=null;
            }
            if(isrefresh) {
                xRefreshView.stopRefresh();
            }else if(isloadmore){
                xRefreshView.stopLoadMore();
            }
            lastRefreshTime = xRefreshView.getLastRefreshTime();
            ShoplistBean shoplistBeanData = (ShoplistBean) data;
            if(pageIndex>1) {
                List<ShoplistBean.DataBean> dataLoad = shoplistBeanData.getData();
                shoplistBean.addAll(dataLoad);
                if(mContentAdapter!=null) {
                    mContentAdapter.notifyDataSetChanged();
                }

            }else{
                shoplistBean = shoplistBeanData.getData();
                mContentAdapter=new CommonAdapter<ShoplistBean.DataBean>(this,shoplistBean,R.layout.item_findshop_shoplist) {
                    @Override
                    public void convert(MyViewHolder holder, int position) {
                        final ShoplistBean.DataBean dataBean = shoplistBean.get(position);

                        ImageView lableView = (ImageView) holder.getView(R.id.iv_lable_shop);

                        Glide.with(HomeFindbusinshopActivity.this).load(dataBean.getNvc_Logo()).override(DensityUtil.dip2px(60),DensityUtil.dip2px(60)).into(lableView);

                        holder.setOnClickListener(R.id.ll_home_seek_shop, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent();
                                intent.setClass(HomeFindbusinshopActivity.this,ShopDetailsActivity.class);
                                intent.putExtra("nvc_num",dataBean.getNvc_No());
                                intent.putExtra("BusinessID",dataBean.getI_Id());
                                startActivity(intent);
                            }
                        });
                        holder.setText(R.id.tv_nvcName,dataBean.getNvc_StoreName());
                        holder.setText(R.id.tv_item_taocan,String.valueOf(dataBean.getProductCount()));
                        holder.setText(R.id.tv_examplecount,String.valueOf(dataBean.getCasesCount()));
                        holder.setText(R.id.tv_fensi,String.valueOf(dataBean.getBusinessMemberCount()));
                    }
                };
                shopListView.setAdapter(mContentAdapter);
                pageIndex++;
            }
            switch (selectModel) {
                case 0://全部,默认
                    break;
                case 1://分类
                    break;
                case 2://按区域
                    break;
            }
        }else if(data instanceof CateguryGridViewBean){
            CateguryGridViewBean categryData= (CateguryGridViewBean) data;
            switch (categryData.getResCode()) {
                    case "0000":
                        categryListData = categryData.getData();
                        break;
            }

        }else if(data instanceof CityAreaBean){
            CityAreaBean areaData= (CityAreaBean) data;
            cityAreaList = areaData.getData();
        }
    }
    @Override
    public void onError(ErrorBean errorBean) {
        switch (errorBean.getErrorCode()) {
                case NONET:
                    notifyViewLay(NODATA);
                break;
                 default:
                     CUtils.showDataErrToast(this);
        }
    }
    class MyListAdapter extends BaseAdapter{
        private List<String> strList;
        private String title;
        public MyListAdapter (List<String> strList ,String title){
            this.strList=strList;
            this.title=title;
        }
        @Override
        public int getCount() {
            return strList.size();
        }
        @Override
        public Object getItem(int position) {
            return strList.get(position);
        }
        @Override
        public long getItemId(int position) {
            return 0;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            convertView=View.inflate(HomeFindbusinshopActivity.this,R.layout.item_popupwindow_selecter,null);
            String strInfo = strList.get(position);
            if(position==0) {
                LinearLayout layAll = (LinearLayout) convertView.findViewById(R.id.lay_all);
                layAll.setVisibility(View.VISIBLE);
                TextView textViewAll = (TextView) convertView.findViewById(R.id.tv_all);
                textViewAll.setVisibility(View.VISIBLE);
                textViewAll.setText(title);
                textViewAll.setOnClickListener(HomeFindbusinshopActivity.this);
            }
            TextView textView = (TextView)convertView.findViewById(R.id.tv_listview_popupwindow);
            textView.setTextColor(getResources().getColor(R.color.colorFontGray2));
            textView.setText(strInfo);
            return convertView;
        }
    }
    //初始化上啦刷新
    public void initRefreshView() {
        //是否允许下拉刷新
        xRefreshView.setPullRefreshEnable(true);
        // 设置是否可以上拉加载
        xRefreshView.setPullLoadEnable(true);
        // 设置刷新完成以后，headerview固定的时间
        xRefreshView.setPinnedTime(1000);
        // 设置支持自动刷新
        xRefreshView.setAutoLoadMore(false);
        // 设置上次刷新的时间
        xRefreshView.restoreLastRefreshTime(lastRefreshTime);
        xRefreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener() {
            @Override
            public void onRefresh() {
                pageIndex=1;
                isrefresh=true;
                isloadmore=false;
                switch (selectModel) {
                    case 0://全部
                        getdataFromNet(1,"1",0,"2",3);
                        break;
                    case 1://分类
                        getdataFromNet(1, categoryId+"" ,areaID,"2",3);
                        break;
                    case 2://按区域
                        getdataFromNet(1, categoryId+"",areaID,"2",3);
                        break;
                }
            }
            @Override
            public void onLoadMore(boolean isSlience) {
                switch (selectModel) {
                    case 0://全部
                        getdataFromNet(pageIndex,"1",0,"2",3);
                        break;
                    case 1://分类
                        getdataFromNet(pageIndex, categoryId+"" ,areaID,"2",3);
                        break;
                    case 2://按区域
                        getdataFromNet(pageIndex, categoryId+"",areaID,"2",3);
                        break;
                }
                isloadmore=true;
                isrefresh=false;
                xRefreshView.stopLoadMore();
            }
            @Override
            public void onRelease(float direction) {
                super.onRelease(direction);

            }
        });
    }
    private void resetPageIndex(){
        pageIndex=1;
    }
    private void notifyViewLay(int state){
        switch (state) {
            case HAVEDATA:
                mProgressLay.setVisibility(View.GONE);
                mContentLay.setVisibility(View.VISIBLE);
                mNoNetLay.setVisibility(View.GONE);

                break;
            case NODATA:
                mProgressLay.setVisibility(View.GONE);
                mContentLay.setVisibility(View.GONE);
                mNoNetLay.setVisibility(View.VISIBLE);
                break;
            case DATAERROR:
                break;
        }
    }
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch (buttonView.getId()) {
            case R.id.rbtn_defaultorder:
                if(buttonView.isChecked()) {
                    mOrderLay.setText("默认排序");
                    mOrderLay.setTextColor(getResources().getColor(R.color.colorFontGray2));
                    mOrderLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_gray_down),null);
                    orderIndex=3;
                }
                break;
            case R.id.rbtn_collectorder:
                if(buttonView.isChecked()) {
                    mOrderLay.setText("最多收藏");
                    mOrderLay.setTextColor(getResources().getColor(R.color.colorMainRed));
                    mOrderLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_red_down),null);
                    orderIndex=1;
                }
                break;
            case R.id.rbtn_newreleasectorder:
                if(buttonView.isChecked()) {
                    mOrderLay.setText("最新发布");
                    mOrderLay.setTextColor(getResources().getColor(R.color.colorMainRed));
                    mOrderLay.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.arror_red_down),null);
                    orderIndex=2;
                }
                break;
        }
    }
}
